package facade;

import javax.swing.JOptionPane;

import impl.repository.StubCustomerRepositoryImpl;
import impl.repository.StubOrderRepositoryImpl;
import impl.repository.StubProductApparelRepositoryImpl;
import impl.repository.StubProductCampingRepositoryImpl;
import impl.repository.StubProductGearRepositoryImpl;
import impl.repository.StubUsersRepositoryImpl;
import domain.Customer;
import domain.Order;
import domain.ProductApparel;
import domain.ProductCamping;
import domain.ProductGear;
import domain.User;

public class facade {

	public boolean InserirUsuario(User user) {

		StubUsersRepositoryImpl suri = new StubUsersRepositoryImpl();
		if (suri.add(user)) {
			JOptionPane.showMessageDialog(null,
					"Usuario cadastrado com sucesso!!");
			return true;
		}
		return false;
	}

	public boolean logar(String login, String pass) {

		StubUsersRepositoryImpl suri = new StubUsersRepositoryImpl();
		return suri.checkUser(login, pass);
	}

	public User procurarUsuario(String login) {

		StubUsersRepositoryImpl suri = new StubUsersRepositoryImpl();
		return  suri.findBylogin(login);
		 

	}

	public boolean realizarVenda(Order order) {

		StubOrderRepositoryImpl sori = new StubOrderRepositoryImpl();
		return sori.add(order);
	}

	public boolean cadastrarProdctGear(ProductGear product) {

		StubProductGearRepositoryImpl spgr = new StubProductGearRepositoryImpl();
		return spgr.add(product);

	}

	public boolean cadastrarProdctApparel(ProductApparel product) {

		StubProductApparelRepositoryImpl spgr = new StubProductApparelRepositoryImpl();
		return spgr.add(product);

	}

	public boolean cadastrarProdctCamping(ProductCamping product) {

		StubProductCampingRepositoryImpl spcr = new StubProductCampingRepositoryImpl();
		return spcr.add(product);

	}

	public boolean alterarProdctGear(ProductGear antes, ProductGear depois) {

		StubProductGearRepositoryImpl spgr = new StubProductGearRepositoryImpl();
		return spgr.edit(antes, depois);

	}

	public boolean alterarProdctApparel(ProductApparel antes,
			ProductApparel depois) {

		StubProductApparelRepositoryImpl spar = new StubProductApparelRepositoryImpl();
		return spar.edit(antes, depois);

	}

	public boolean alterarProdctCamping(ProductCamping antes,
			ProductCamping depois) {

		StubProductCampingRepositoryImpl spcr = new StubProductCampingRepositoryImpl();
		return spcr.edit(antes, depois);
	}

	public boolean deletarProdctGear(ProductGear product) {

		StubProductGearRepositoryImpl spgr = new StubProductGearRepositoryImpl();
		return spgr.delete(product.getId());

	}

	public boolean deletarProdctApparel(ProductApparel product) {

		StubProductApparelRepositoryImpl spar = new StubProductApparelRepositoryImpl();
		return spar.delete(product.getId());

	}

	public boolean deletarProdctCamping(ProductCamping product) {

		StubProductCampingRepositoryImpl spcr = new StubProductCampingRepositoryImpl();
		return spcr.delete(product.getId());

	}
	
	public boolean addCustomer(Customer customer){
		
		StubCustomerRepositoryImpl scri = new StubCustomerRepositoryImpl();
		return scri.add(customer);
	}
	
	public boolean editCustomer(Customer antes, Customer depois){
		
		StubCustomerRepositoryImpl scri = new StubCustomerRepositoryImpl();
		return scri.edit(antes, depois);
	}

}
